﻿package net.area80.sitemanager.popup
{
	import flash.display.MovieClip;
	import flash.events.Event;
	import net.area80.sitemanager.popup.*;
	
	/**
	* GoBackPopup
	* @author Wissarut Pimanmassuriya
	*/
	public class GoBackPopup extends AbstractPopup
	{
		private var shown:Boolean = false;
		
		public function GoBackPopup ():void {
				stop();
				addEventListener(Event.REMOVED_FROM_STAGE, clearUpdate, false, 0, true);
		}

		private function clearUpdate (e:Event=null):void {
				stop();
				removeEventListener(Event.REMOVED_FROM_STAGE, clearUpdate);
				removeEventListener(Event.ENTER_FRAME, showUpdate);
				removeEventListener(Event.ENTER_FRAME, hideUpdate);
		}
	
		private function showUpdate (e:Event):void {
				if (currentFrame == totalFrames) {
					gotoAndStop(totalFrames);
					removeEventListener(Event.ENTER_FRAME, showUpdate);
					onInit();
				} else {
					nextFrame();
				}
		}
		private function hideUpdate (e:Event):void {
				if (currentFrame == 1) {
					gotoAndStop(1);
					removeEventListener(Event.ENTER_FRAME, hideUpdate);
					onOut();
				} else {
					prevFrame();
				}
		}
		
		public override function moveIn ():void {
				clearUpdate();
				addEventListener(Event.ENTER_FRAME, showUpdate, false, 0, true);
			
		}
		public override function moveOut ():void {
				clearUpdate();
				addEventListener(Event.ENTER_FRAME, hideUpdate, false, 0, true);
		}
		
	}
	
}